import {createBrowserRouter, Link} from 'react-router-dom'
import App from '../App'
import { ErrorBlock } from 'antd-mobile'

const routes=createBrowserRouter([
    {
        path:'/',
        elementL:<App/>,
        children:[
            {
                path:'/home',
                async lazy(){
                    const {default:Home,loader}=await import('../pages/home/Index')
                    return{
                        element:<Home/>,
                        loader
                    }
                }
            },
            {
                path:'/todo',
                async lazy(){
                    const {default:Todo,loader}=await import('../pages/todo/Index')
                    return{
                        element:<Todo/>,
                        loader
                    }
                }
            },
            {
                path:'/message',
                async lazy(){
                    const {default:Message,loader}=await import('../pages/message/Index')
                    return{
                        element:<Message/>,
                        loader
                    }
                }
            },
            {
                path:'/my',
                async lazy(){
                    const {default:My,loader}=await import('../pages/my/Index')
                    return{
                        element:<My/>,
                        loader
                    }
                }
            },
        ]
    },
    {
        path:'*',
        element:(
            <ErrorBlock fullPage description={<Link to='/home'>返回首页</Link>}/>
        )
    }
])
export default routes;
